package com.ruoyi.personage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.personage.domain.PositionPersonage;
import com.ruoyi.personage.service.IPositionPersonageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 个人位置信息管理Controller
 *
 * @author zhezhi
 * @date 2022-10-02
 */
@RestController
@RequestMapping("/position/personage")
public class PositionPersonageController extends BaseController
{
    @Autowired
    private IPositionPersonageService positionPersonageService;

    /**
     * 查询个人位置信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('position:personage:list')")
    @GetMapping("/list")
    @ApiOperation("查询个人位置信息管理列表")
    public TableDataInfo list(PositionPersonage positionPersonage)
    {
        startPage();
        List<PositionPersonage> list = positionPersonageService.selectPositionPersonageList(positionPersonage);
        return getDataTable(list);
    }

    /**
     * 导出个人位置信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('position:personage:export')")
    @Log(title = "个人位置信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出个人位置信息管理列表")
    public void export(HttpServletResponse response, PositionPersonage positionPersonage)
    {
        List<PositionPersonage> list = positionPersonageService.selectPositionPersonageList(positionPersonage);
        ExcelUtil<PositionPersonage> util = new ExcelUtil<PositionPersonage>(PositionPersonage.class);
        util.exportExcel(response, list, "个人位置信息管理数据");
    }

    /**
     * 获取个人位置信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('position:personage:query')")
    @GetMapping(value = "/{personageId}")
    @ApiOperation("获取个人位置信息管理详细信息")
    public AjaxResult getInfo(@PathVariable("personageId") Long personageId)
    {
        return AjaxResult.success(positionPersonageService.selectPositionPersonageByPersonageId(personageId));
    }

    /**
     * 新增个人位置信息管理
     */
    @PreAuthorize("@ss.hasPermi('position:personage:add')")
    @Log(title = "个人位置信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增个人位置信息管理")
    public AjaxResult add(@RequestBody PositionPersonage positionPersonage)
    {
        return toAjax(positionPersonageService.insertPositionPersonage(positionPersonage));
    }

    /**
     * 修改个人位置信息管理
     */
    @PreAuthorize("@ss.hasPermi('position:personage:edit')")
    @Log(title = "个人位置信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改个人位置信息管理")
    public AjaxResult edit(@RequestBody PositionPersonage positionPersonage)
    {
        return toAjax(positionPersonageService.updatePositionPersonage(positionPersonage));
    }

    /**
     * 删除个人位置信息管理
     */
    @PreAuthorize("@ss.hasPermi('position:personage:remove')")
    @Log(title = "个人位置信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{personageIds}")
    @ApiOperation("删除个人位置信息管理")
    public AjaxResult remove(@PathVariable Long[] personageIds)
    {
        return toAjax(positionPersonageService.deletePositionPersonageByPersonageIds(personageIds));
    }
}
